package com.nut.lmsc.api.merchant;

import com.nut.lmsc.common.Holder;
import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.Member;
import com.nut.lmsc.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/merchant/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    @GetMapping("/get")
    public Result<Member> get() {
        Long memberId = Holder.MERCHANT_JWT_THREAD_LOCAL.get().getMemberId();
        return memberService.getById(memberId);
    }

    @PutMapping
    public Result update(@RequestBody Member member) {
        Long memberId = Holder.CLIENT_JWT_THREAD_LOCAL.get().getMemberId();
        member.setId(memberId);
        return memberService.updateById(member);
    }

}
